package com.foreknow.demo08;

public class Student1 {
    String name;
    int id;
    int score;
    public Student1(String name,int id, int score){
        this.name = name;
        this.id = id;
        this.score = score;
    }

    public Student1[]c(Student1[]d){
        for(int i=1;i<d.length;i++){
            for(int j=0;j<d.length-i;j++){
                if(d[i].score<d[i+1].score){
                    Student1 temp = d[i];
                    d[i]=d[i+1];
                    d[i+1]=temp;
                }
            }
        }
        return d;
    }

    public static void main(String[] args) {
        Student1 std1 = new Student1("zhangsan",20,80);
        Student1 std2 = new Student1("lisi",45,89);
        Student1 std3 = new Student1("zwangwu",43,100);
        Student1[] a = {std1,std2,std3};
        Student1 []array = std1.c(a);

        for(int i = 0; i<array.length;i++){
            Student1 student1 = array[i];
            System.out.println(student1.id +student1.name+student1.score);
        }


    }

}
